package javafx.officialdemo.label;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.OverrunStyle;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

public class FXLabel extends Application{

	public void start(Stage primaryStage) throws Exception {
		GridPane root = new GridPane();
		root.getChildren().add(null);
		
		
		
		Scene scene = new Scene(root, 300, 250);
		primaryStage.setScene(scene);
		primaryStage.show();
	}
	
	
	public void createLabel(){
		//label构造器
		//An empty label
		Label label1 = new Label();
		//A label with the text element
		Label label2 = new Label("Search");
		//A label with the text element and graphical icon
		Image image = new Image(getClass().getResourceAsStream("labels.jpg"));
		Label label3 = new Label("Search", new ImageView(image));
		
		/**
		 * 给label设置字符串或者图片
		 * Label label1 = new Label("Search");
		 * Image image = new Image(getClass().getResourceAsStream("labels.jpg"));
		 * label1.setGraphic(new ImageView(image));
		 * label1.setTextFill(Color.web("#0076a3"));
		 */
		
		/**
		 * 设置label字体
		 * Use a constructor of the Font class
		 * label1.setFont(new Font("Arial", 30));
		 * 
		 * Use the font method of the Font class
		 * label2.setFont(Font.font("Cambria", 32));
		 */
		
		/**
		 * When you create a label, sometimes you must fit it within a space
		 * that is smaller than you need to render. To break up (wrap) the text 
		 * so that is can fit into the layout area, 
		 * set the true value for the setWrapText method.
		 * 以上描述 貌似 是设置 label换行.
		 * 
		 * label3.setWrapText(true);
		 */
		
		/**
		 * 设置 lable超出  大小范围的 部分 处理方式
		 * label1.setTextOverrun(OverrunStyle.CLIP);
		 */
		
		
		/**
		 *  旋转 平移
		 * label2.setRotate(270);
		 * label2.setTranslateY(50);
		 */
		
		/**
		 * 设置 缩放
		 * label3.setOnMouseEntered((MouseEvent e) -> {
		 *  label3.setScaleX(1.5);
		 *   label3.setScaleY(1.5);
		 * });
		 *
		 *	label3.setOnMouseExited((MouseEvent e) -> {
		 *    	label3.setScaleX(1);
		 *   	label3.setScaleY(1);
		 *	});
		 */
	}
	
	public static void main(String[] args) {
		launch(null);
	}
}
